#include "BSTree.h"

void Test1(){
    int a[] = {8,3,1,10,6,4,7,14,13};
    Key::BSTree<int> t;
    for (auto e : a) {
        t.Insert(e);
    }
    t.InOrder();
    t.Insert(66);
    t.InOrder();
    t.Erase(3);
    t.InOrder();
    t.Erase(1);
    t.InOrder();
    t.Erase(8);
    t.InOrder();
    t.Erase(14);
    t.InOrder();
    t.Erase(6);
    t.InOrder();
}

void Test2(){
    int a[] = {8,3,1,10,6,4,7,14,13};
    Key::BSTree<int> t1;
    for (auto e : a) {
        t1.Insert(e);
    }
    t1.InOrder();

/*    Key::BSTree<int> t2(t1);
    t2.InOrder();

    Key::BSTree<int> t3 = t2;
    t3.InOrder();*/

    t1.EraseR(10);
    t1.InOrder();
}

void Test3(){
    string arr[] = {"apple", "watermelon", "banana", "apple", "apple", "watermelon", "apple"};
    Key_value::BSTree<string, int> countTree;
    for (const auto& str : arr) {
        auto ret = countTree.Find(str);
        if (ret == nullptr)
            countTree.Insert(str, 1);
        else
            ret->_value++;
    }
    countTree.InOrder();
}

int main() {
    Test2();
    return 0;
}
